package com.example.lenovo.tianqi.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by lenovo on 2018/1/9.
 */

public class MyFragmentPagerAdapter extends FragmentPagerAdapter{
    private ArrayList<Fragment> fragments;
    public MyFragmentPagerAdapter(FragmentManager fm,ArrayList<Fragment> fragments) {
        super(fm);
        this.fragments=fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
//viewPager的适配器中getPageTitle方法会返回position位置的PagerTab的标题
    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
            case 0:
                return "天气状况";
            default:
                return "我管理的城市";
        }
    }
}
